﻿using UnityEngine;
using System.Collections;

public class PlayerInfoMenuLogic : SQMenuBase
{
    public GameObject _peopleInfoMenu;
    public override void onStart()
    {
        base.onStart();
        initPeopleInfo();

    }
    public override void OnClick(GameObject btn)
    {
        switch (btn.name)
        {
            case "btnPlayerClose":
                btn.gameObject.GetComponent<UIPlaySound>().Play();
                _peopleInfoMenu.gameObject.SetActive(false);
                break;
            default:
                break;
        }
    }
    /// <summary>
    /// 初始化人物信息界面
    /// </summary>
    public void initPeopleInfo()
    {
        PlayerInfo data = GlobalDataManager.instance.playerData;
        foreach (System.Reflection.PropertyInfo p in data.GetType().GetProperties())
        {
            string path = "img_" + p.Name + "/txt_" + p.Name;
            string showTxt = p.GetValue(data, null).ToString();
            if (p.Name.Equals("winRate"))
            {
                showTxt += "%";
            }

            SparkExtensions.SetChildText(_peopleInfoMenu, path, showTxt);

        }
        GameObject UISlider = _peopleInfoMenu.FindChild("img_winRate/imgRateBack");
        UISlider.ProgressBar(data.winRate);
    }
}
